//
//  PxWebController.m
//  PxHelper
//
//  Created by lpc on 2019/10/18.
//  Copyright © 2019 lpc. All rights reserved.
//

#import "PxWebController.h"
#import "PxWebView.h"

@interface PxWebController ()<ReWebViewDelegate>

@property (weak, nonatomic) IBOutlet PxWebView *webView;

@end

@implementation PxWebController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.webView.ReDelegate = self;
    NSString *string = @"https://www.baidu.com";
    NSURL *url = [NSURL URLWithString:string];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:request];
}

- (void)goBack
{
    if (self.webView.canGoBack) {
        if (self.webView.isLoading) {
            [self.webView stopLoading];
        }
        [self.webView goBack];
    }
    else{
        [self.navigationController popViewControllerAnimated:YES];
    }
}

#pragma mark - ReWebViewDelegate
- (BOOL)reWebView:(ReWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    return YES;
}
- (void)reWebViewDidStartLoad:(ReWebView *)webView
{

}
- (void)reWebViewDidFinishLoad:(ReWebView *)webView
{
    self.navBarTitle = webView.title;
}
- (void)reWebView:(ReWebView *)webView didFailLoadWithError:(NSError *)error
{

}

@end
